import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('@/views/login/index.vue')
    },
    {
      path: '/register',
      name: 'Register',
      component: () => import('@/views/register/index.vue')
    },
    {
      path: '/admin',
      name: 'AdminLayout',
      component: () => import('@/views/adminlayout/index.vue'),
      children: [
        { path: '', component: () => import('@/views/adminlayout/dashboard/Dashboard.vue') },
        { path: 'article', component: () => import('@/views/adminlayout/article/Article.vue') },
        { path: 'category', component: () => import('@/views/adminlayout/category/Category.vue') },
        { path: 'course', component: () => import('@/views/adminlayout/course/Course.vue') },
        { path: 'chapter', component: () => import('@/views/adminlayout/chapter/Chapter.vue') },
        { path: 'user', component: () => import('@/views/adminlayout/user/User.vue') },
        { path: 'comment', component: () => import('@/views/adminlayout/comment/Comment.vue') },
        { path: 'attachment', component: () => import('@/views/adminlayout/attachment/Attachment.vue') }
      ]
    },
    {
      path: '/home',
      name: 'HomeLayout',
      component: () => import('@/views/layout/index.vue'),
      children: [
        { path: '', component: () => import('@/views/layout/home/Home.vue') },
        { path: 'blog', component: () => import('@/views/layout/blog/Blog.vue') },
        { path: 'blog/article/:id', component: () => import('@/views/layout/blog/ArticleDetail.vue') },
        { path: 'course', component: () => import('@/views/layout/course/Course.vue') },
        { path: 'course/search', component: () => import('@/views/layout/course/SearchCourse.vue') },
        { path: 'course/:id', component: () => import('@/views/layout/course/CourseDetail.vue') },
        { path: 'chapter/:id', component: () => import('@/views/layout/course/ChapterDetail.vue') },
        { path: 'profile', component: () => import('@/views/layout/profile/Profile.vue') }
      ]
    },
    { path: '/:pathMatch(.*)*', name: 'NotFound', component: () => import('@/views/notFound/index.vue') }
  ],
})

export default router
